{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-10-17T09:28:13.532128Z",
     "start_time": "2025-10-17T09:28:13.520971Z"
    }
   },
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "s = pd.Series(3,index=[1,2,3])\n",
    "s"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1    3\n",
       "2    3\n",
       "3    3\n",
       "dtype: int64"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 30
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T09:28:13.590953Z",
     "start_time": "2025-10-17T09:28:13.581572Z"
    }
   },
   "cell_type": "code",
   "source": [
    "data = {'a':0,'b':1,'c':2}\n",
    "s1 = pd.Series(data,index=['a','b','c','d'])\n",
    "s"
   ],
   "id": "8d706cca6eaba3b9",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1    3\n",
       "2    3\n",
       "3    3\n",
       "dtype: int64"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 31
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T09:28:13.617001Z",
     "start_time": "2025-10-17T09:28:13.605836Z"
    }
   },
   "cell_type": "code",
   "source": [
    "df1 = pd.DataFrame(np.arange(12).reshape(3,4))\n",
    "df1\n"
   ],
   "id": "ef3addf61bbeb8b0",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "   0  1   2   3\n",
       "0  0  1   2   3\n",
       "1  4  5   6   7\n",
       "2  8  9  10  11"
      ],
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>8</td>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 32
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T09:28:13.666781Z",
     "start_time": "2025-10-17T09:28:13.653127Z"
    }
   },
   "cell_type": "code",
   "source": [
    "\n",
    "data = np.arange(12).reshape(3,4)\n",
    "df2 = pd.DataFrame(data,index=['a','b','c'],columns=['c1','c2','c3','c4'])\n",
    "df2"
   ],
   "id": "69f6e53b035a2b09",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "   c1  c2  c3  c4\n",
       "a   0   1   2   3\n",
       "b   4   5   6   7\n",
       "c   8   9  10  11"
      ],
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>c1</th>\n",
       "      <th>c2</th>\n",
       "      <th>c3</th>\n",
       "      <th>c4</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>8</td>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 33
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T09:28:13.719626Z",
     "start_time": "2025-10-17T09:28:13.705046Z"
    }
   },
   "cell_type": "code",
   "source": [
    "data = {'mouth':['w1','w2','w3','w4'],\n",
    "        'income':[1000,2000,3000,4000],\n",
    "        'tax':[500,4500,2000,10000]\n",
    "        }\n",
    "df3 = pd.DataFrame(data)\n",
    "df3"
   ],
   "id": "d78ff68982586e98",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "  mouth  income    tax\n",
       "0    w1    1000    500\n",
       "1    w2    2000   4500\n",
       "2    w3    3000   2000\n",
       "3    w4    4000  10000"
      ],
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>mouth</th>\n",
       "      <th>income</th>\n",
       "      <th>tax</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>w1</td>\n",
       "      <td>1000</td>\n",
       "      <td>500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>w2</td>\n",
       "      <td>2000</td>\n",
       "      <td>4500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>w3</td>\n",
       "      <td>3000</td>\n",
       "      <td>2000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>w4</td>\n",
       "      <td>4000</td>\n",
       "      <td>10000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 34
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T09:28:13.778983Z",
     "start_time": "2025-10-17T09:28:13.770774Z"
    }
   },
   "cell_type": "code",
   "source": [
    "print('值',df3.values)\n",
    "print('列名',df3.columns)\n",
    "print('维度',df3.ndim)\n",
    "print('元素个数',df3.size)\n",
    "print('索引',df3.index)"
   ],
   "id": "cf627fc411a775e3",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "值 [['w1' 1000 500]\n",
      " ['w2' 2000 4500]\n",
      " ['w3' 3000 2000]\n",
      " ['w4' 4000 10000]]\n",
      "列名 Index(['mouth', 'income', 'tax'], dtype='object')\n",
      "维度 2\n",
      "元素个数 12\n",
      "索引 RangeIndex(start=0, stop=4, step=1)\n"
     ]
    }
   ],
   "execution_count": 35
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T09:39:32.556409Z",
     "start_time": "2025-10-17T09:39:32.498916Z"
    }
   },
   "cell_type": "code",
   "source": [
    "df3 = pd.read_csv('phones.csv',header=None,encoding='gbk')\n",
    "df3.head()"
   ],
   "id": "dcbeb11a4e2b0fdb",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "    0          1                                                2       3\n",
       "0  序号       手机品牌                                             手机描述      价格\n",
       "1   1         小米                小米9 8GB+128GB 全息幻彩蓝 移动联通电信4G全网通手机  3,139 \n",
       "2   2         小米             小米9 SE 6GB+128GB 全息幻彩蓝 移动联通电信4G全网通手机  2,189 \n",
       "3   3  Apple 苹果           Apple 苹果 iPhone Xs Max 64GB 深空灰色 全网通 手机  7,728 \n",
       "4   4  Apple 苹果     Apple iPhone 8 苹果8 (A1863) 64GB 金色 移动联通电信4G手机  3,888 "
      ],
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>序号</td>\n",
       "      <td>手机品牌</td>\n",
       "      <td>手机描述</td>\n",
       "      <td>价格</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>小米</td>\n",
       "      <td>小米9 8GB+128GB 全息幻彩蓝 移动联通电信4G全网通手机</td>\n",
       "      <td>3,139</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>小米</td>\n",
       "      <td>小米9 SE 6GB+128GB 全息幻彩蓝 移动联通电信4G全网通手机</td>\n",
       "      <td>2,189</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>Apple 苹果</td>\n",
       "      <td>Apple 苹果 iPhone Xs Max 64GB 深空灰色 全网通 手机</td>\n",
       "      <td>7,728</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>Apple 苹果</td>\n",
       "      <td>Apple iPhone 8 苹果8 (A1863) 64GB 金色 移动联通电信4G手机</td>\n",
       "      <td>3,888</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 36
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "",
   "id": "4e35de6c2b679204"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
